package com.gq.utils;


import android.content.Context;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.view.MotionEvent;

public class CustomViewPager extends ViewPager {

	private boolean enabled;
	private boolean forceDisable = false;
	
	public CustomViewPager(Context context) {
		super(context);
		this.enabled = true;
	}

	public CustomViewPager(Context context, AttributeSet attrs) {
		super(context, attrs);
		this.enabled = true;
	}

	@Override
	public boolean onTouchEvent(MotionEvent ev) {
		if (this.enabled) {
			return super.onTouchEvent(ev);
		}
		return false;
	}
	
	@Override
	public boolean onInterceptTouchEvent(MotionEvent ev) {
		if (this.enabled && !forceDisable) {
			return super.onInterceptTouchEvent(ev);
		}
		return false;
	}
	
	public void setPagingEnabled(boolean enabled) {
		this.enabled = enabled;
	}
	
	public void forceDisablePaging() {
		forceDisable = true;
	}
}
